<template>
  <div>
    <el-form ref="ruleForm" class="elForm" label-position="right">
      <!--待扣费用-->
      <el-row :gutter="24">
        <el-col :span="8">
          <span>待扣费用</span>
        </el-col>
      </el-row>
      <!--未发起 已发起 提前还车-->
      <template v-if="ruleForm.returnCategory === '1' || ruleForm.returnCategory === '5'">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="违章费用:">
              <span> {{ format_thousand(ruleForm.violationFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆租金欠款金额:">
              <span>{{ format_thousand(ruleForm.rentArrears) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="违约金:">
              <span>{{ format_thousand(ruleForm.defaultDeduction) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="车损:">
              <span>{{ format_thousand(ruleForm.vehicleDamageFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加速折旧费:">
              <span>{{ format_thousand(ruleForm.depreciation) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="超里程费:">
              <span>{{ format_thousand(ruleForm.overMileageFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="其他扣款:">
              <span>{{ format_thousand(ruleForm.otherFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>
      </template>

      <!--期满还车-退保证金-->
      <template v-if="ruleForm.returnCategory === '2'">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="违章费用:">
              <span> {{ format_thousand(ruleForm.violationFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆租金欠款金额:">
              <span>{{ format_thousand(ruleForm.rentArrears) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车损:">
              <span>{{ format_thousand(ruleForm.vehicleDamageFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="加速折旧费:">
              <span>{{ format_thousand(ruleForm.depreciation) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="超里程费:">
              <span>{{ format_thousand(ruleForm.overMileageFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="其他扣款:">
              <span>{{ format_thousand(ruleForm.otherFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

      </template>

      <!--租购还车-退保证金 -->
      <template v-if="ruleForm.returnCategory === '3'">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="违章费用:">
              <span> {{ format_thousand(ruleForm.violationFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆租金欠款金额:">
              <span>{{ format_thousand(ruleForm.rentArrears) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="尾款:">
              <span>{{ format_thousand(ruleForm.balancePayment) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="车损:">
              <span>{{ format_thousand(ruleForm.vehicleDamageFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加速折旧费:">
              <span>{{ format_thousand(ruleForm.depreciation) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="超里程费:">
              <span>{{ format_thousand(ruleForm.overMileageFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="违约金:">
              <span>{{ format_thousand(ruleForm.defaultDeduction) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="其他扣款:">
              <span>{{ format_thousand(ruleForm.otherFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>
      </template>

      <!--事故还车-退保证金 -->
      <template v-if="ruleForm.returnCategory === '4'">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="违章费用:">
              <span> {{ format_thousand(ruleForm.violationFee) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="车辆租金欠款金额:">
              <span>{{ format_thousand(ruleForm.rentArrears) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="违约金:">
              <span>{{ format_thousand(ruleForm.defaultDeduction) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="客户理赔款:">
              <span>{{ format_thousand(ruleForm.compensationClaims) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="加速折旧费:">
              <span>{{ format_thousand(ruleForm.depreciation) }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="超里程费:">
              <span>{{ format_thousand(ruleForm.overMileageFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="其他扣款:">
              <span>{{ format_thousand(ruleForm.otherFee) }}</span>
            </el-form-item>
          </el-col>
        </el-row>
      </template>

      <el-row :gutter="24">
        <el-col :span="8">
          <el-form-item label="总计:" class="itemColor">
            <span>{{ format_thousand(ruleForm.totalFee) }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8" class="itemColor">
          <el-form-item label="已缴费:">
            <span>{{ format_thousand(payeeFee) }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8" class="itemColor">
          <el-form-item label="剩余未缴纳:">
            <span>{{ format_thousand(waitAmount) }}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>

</template>

<script>
import * as apis from "@/api/returnMargin";
import {toNumberSub} from "@/utils/utils"
export default {
  name: 'withheldExpense',//待扣费用(未发起 已发起 提前还车)
  props: {
    ruleForm: {
      type: Object,
      default: {}
    },
    typeBoole: {
      type: Number,
      default: 1
    }
  },
  computed: {},
  watch: {
    ruleForm:{
      handler(val){
        if(val && val.returnCarDepositId && this.num === 0){
          this.num = 1
          this.handleWaitAmount([val.returnCarDepositId])
        }
      },
      immediate:true,
      deep:true
    }
  },
  data() {
    return {
      waitAmount:'',
      payeeFee:'',
      num:0
    };
  },
  created() {

  },
  mounted() {
  },
  methods: {
    handleWaitAmount(id) {
      apis?.queryWaitAmountById(id).then(res => {
        if (res.code === 200) {
          this.waitAmount = res.data
          this.payeeFee  = toNumberSub(Number(this.ruleForm.totalFee) ,Number(this.waitAmount))
          this.$emit('waitAmountInput',this.waitAmount)
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/cwgd/formScss.scss";

.itemColor {
  ::v-deep .el-form-item__label {
    color: red;
  }

  span {
    color: red;
  }


}

::v-deep span:empty::before {
  content: '-';
}
</style>


